/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.logiclander.whozwho.data.dao.hibernate;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NaturalId;

/**
 *
 * @author logiclander
 */
@Entity
@Table(name = "SYSTEMS")
public class System implements Serializable {

  private long sid;
  private String name;
  private Date expired;
  private Set<Application> applications;
  private Set<Role> roles;

  @Id
  @GeneratedValue(generator = "increment")
  @GenericGenerator(name = "increment", strategy = "increment")
  @Column(name = "system_sid", nullable = false)
  public Long getSid() {
    return sid;
  }

  public void setSid(long sid) {
    this.sid = sid;
  }

  @NaturalId
  @Column(name = "system_name", nullable = false)
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  @Column(name = "expired")
  @Temporal(javax.persistence.TemporalType.DATE)
  public Date getExpired() {
    return expired;
  }

  public void setExpired(Date expired) {
    this.expired = expired;
  }

//roles
  @OneToMany
  @JoinColumn(name = "role_sid")
  public Set<Role> getRoles() {
    return roles;
  }

  public void setRoles(Set<Role> roles) {
    this.roles = roles;
  }

//applications
  @OneToMany
  @JoinColumn(name = "application_sid")
  public Set<Application> getApplications() {
    return applications;
  }

  public void setApplications(Set<Application> applications) {
    this.applications = applications;
  }

}
